Published on January 17, 2025

返回

转到题目

解题思路

首先,题目要求的是3个是数的运算最大值 其中可以随意加括号的意思是没有了乘与加法的运算优先级,并且优先级是多种情况 而要求最大值,我们可以贪心考虑

代码

#include<bits/stdc++.h>
using namespace std;
int a,b,c;
int res1,res2;
int main(){
    cin>>a>>b>>c;
    if(a==1||b==1){
        res1 = a+b;
    }
    else{
        res1 = a*b;
    }
    if(c==1){res1+=c;}
    else {res1*=c;}
    
    if(b==1||c==1){
        res2 = c+b;
    }
    else{
        res2 = c*b;
    }
    if(a==1){res2+=a;}
    else {res2*=a;}
    cout<<max(res1,res2)<<endl;
    return 0;
}